/**
 * 作者: sessionliang
 * 时间: 2017-08-20
 * 描述: 档案详情页面
 */
define(function(require, exports, module) {
	"use strict";
	//每一个页面都要引入的工具类
	var CommonTools = require('CommonTools_Core');
	var WindowTools = require('WindowTools_Core');
	//轮播图工具类
	var GallerySliderTools = require('GallerySliderTools_Core');

	//base service
	var baseService = require('Base_Service');
	var studentService = require('Student_Service');
	var enumHelper = require('Common_Enum');
	
	var model = null;

	//每一个页面都要引入的工具类
	// initready 要在所有变量初始化做完毕后
	CommonTools.initReady(initData);
	/**
	 * @description 初始化数据,结合initReady使用
	 * plus情况为plusready
	 * 其它情况为直接初始化
	 */
	function initData() {
		//引入必备文件,下拉刷新依赖于mui与mustache
		CommonTools.importFile([
			'js/libs/mui.min.js'
		], function() {
			initHomePage();
			initListeners();
		});
	}

	/**
	 * @description 监听
	 */
	function initListeners() {

	}

	/**
	 * @description 渲染頁面
	 */
	function initHomePage() {
		var id = WindowTools.getExtraDataByKey("mid");
		studentService.getLearnPort(id, function(retval) {
			model = retval;
			mui("#Code")[0].innerHTML = retval.Code;
			mui("#StudentName")[0].innerHTML = retval.StudentName;
			mui("#DrivingTitle")[0].innerHTML = retval.DrivingTitle;
			mui("#DrivingLicenseType")[0].innerHTML = enumHelper.drivingLicenseTypeFormat(retval.DrivingLicenseType);

			
			if(retval.CourseOneIsComplete){
				mui("#Course1Result")[0].innerHTML = "已通过考试,"+retval.CourseOnePoints;
			}
			else if(retval.CourseOneTimes == 0){
				mui("#Course1Result")[0].innerHTML = "还未学习";
			}
			else{
				mui("#Course1Result")[0].innerHTML = "已累计<span style='color:red;'>"+retval.CourseOneTimes+"</span>小时";
			}
			
			if(retval.CourseTwoIsComplete){
				mui("#Course2Result")[0].innerHTML = "已通过考试,"+retval.CourseTwoPoints;
			}
			else if(retval.CourseTwoTimes == 0){
				mui("#Course2Result")[0].innerHTML = "还未学习";
			}
			else{
				mui("#Course2Result")[0].innerHTML = "已累计<span style='color:red;'>"+retval.CourseTwoTimes+"</span>小时";
			}
			
			if(retval.CourseThreeIsComplete){
				mui("#Course3Result")[0].innerHTML = "已通过考试,"+retval.CourseThreePoints;
			}
			else if(retval.CourseThreeTimes == 0){
				mui("#Course3Result")[0].innerHTML = "还未学习";
			}
			else{
				mui("#Course3Result")[0].innerHTML = "已累计<span style='color:red;'>"+retval.CourseThreeTimes+"</span>小时";
			}
			
			if(retval.CourseFourIsComplete){
				mui("#Course4Result")[0].innerHTML = "已通过考试,"+retval.CourseFourPoints;
			}
			else if(retval.CourseFourTimes == 0){
				mui("#Course4Result")[0].innerHTML = "还未学习";
			}
			else{
				mui("#Course4Result")[0].innerHTML = "已累计<span style='color:red;'>"+retval.CourseFourTimes+"</span>小时";
			}
			
			if(retval.IsGetCert){
				mui("#license")[0].innerHTML = '已获取';
			}else{
				mui("#license")[0].innerHTML = '未获取';
			}
		});
	}
});